home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / sdct.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.4 KB  |  119 lines

  1. /* Copyright (C) 1994, 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: sdct.h,v 1.2 2000/09/19 19:00:49 lpd Exp $ */
  20. /* Definitions for DCT filters */
  21. /* Requires stream.h, strimpl.h, jpeg/jpeglib.h */
  22.  
  23. #ifndef sdct_INCLUDED
  24. #  define sdct_INCLUDED
  25.  
  26. #include <setjmp.h>        /* for jmp_buf */
  27.  
  28. /* ------ DCT filters ------ */
  29.  
  30. /*
  31.  * Define the stream state.
  32.  * The jpeg_xxx_data structs are allocated in immovable memory
  33.  * to simplify use of the IJG library.
  34.  */
  35. #define jpeg_stream_data_common\
  36.         /* We put a copy of the stream template here, because */\
  37.         /* the minimum buffer sizes depend on the image parameters. */\
  38.     stream_template template;\
  39.     struct jpeg_error_mgr err;\
  40.     jmp_buf exit_jmpbuf;\
  41.     gs_memory_t *memory;    /* heap for library allocations */\
  42.         /* The following are documented in Adobe TN 5116. */\
  43.     int Picky;        /* 0 or 1 */\
  44.     int Relax        /* 0 or 1 */
  45. typedef struct jpeg_stream_data_s {
  46.     jpeg_stream_data_common;
  47. } jpeg_stream_data;
  48.  
  49. /* Define initialization for the non-library part of the stream state. */
  50. #define jpeg_stream_data_common_init(pdata)\
  51.   ((pdata)->Picky = 0, (pdata)->Relax = 0)
  52.  
  53. typedef struct jpeg_compress_data_s {
  54.     jpeg_stream_data_common;
  55.     /* cinfo must immediately follow the common fields */
  56.     struct jpeg_compress_struct cinfo;
  57.     struct jpeg_destination_mgr destination;
  58.     byte finish_compress_buf[100];
  59.     int fcb_size, fcb_pos;
  60. } jpeg_compress_data;
  61.  
  62. typedef struct jpeg_decompress_data_s {
  63.     jpeg_stream_data_common;
  64.     /* dinfo must immediately follow the common fields, */
  65.     /* so that it has same offset as cinfo. */
  66.     struct jpeg_decompress_struct dinfo;
  67.     struct jpeg_source_mgr source;
  68.     long skip;            /* # of bytes remaining to skip in input */
  69.     bool input_eod;        /* true when no more input data available */
  70.     bool faked_eoi;        /* true when fill_input_buffer inserted EOI */
  71.     byte *scanline_buffer;    /* buffer for oversize scanline, or NULL */
  72.     uint bytes_in_scanline;    /* # of bytes remaining to output from same */
  73. } jpeg_decompress_data;
  74.  
  75. /* The stream state itself.  This is kept in garbage-collectable memory. */
  76. typedef struct stream_DCT_state_s {
  77.     stream_state_common;
  78.     /* The following are set before initialization. */
  79.     /* Note that most JPEG parameters go straight into */
  80.     /* the IJG data structures, not into this struct. */
  81.     gs_const_string Markers;    /* NULL if no Markers parameter */
  82.     float QFactor;
  83.     int ColorTransform;        /* -1 if not specified */
  84.     bool NoMarker;        /* DCTEncode only */
  85.     gs_memory_t *jpeg_memory;    /* heap for library allocations */
  86.     /* This is a pointer to immovable storage. */
  87.     union _jd {
  88.     jpeg_stream_data *common;
  89.     jpeg_compress_data *compress;
  90.     jpeg_decompress_data *decompress;
  91.     } data;
  92.     /* DCTEncode sets this before initialization;
  93.      * DCTDecode cannot set it until the JPEG headers are read.
  94.      */
  95.     uint scan_line_size;
  96.     /* The following are updated dynamically. */
  97.     int phase;
  98. } stream_DCT_state;
  99.  
  100. /* The state descriptor is public only to allow us to split up */
  101. /* the encoding and decoding filters. */
  102. extern_st(st_DCT_state);
  103. #define public_st_DCT_state()    /* in sdctc.c */\
  104.   gs_public_st_const_strings1(st_DCT_state, stream_DCT_state,\
  105.     "DCTEncode/Decode state", dct_enum_ptrs, dct_reloc_ptrs, Markers)
  106.  
  107. /*
  108.  * NOTE: the client *must* invoke the set_defaults procedure in the
  109.  * template before calling the init procedure.
  110.  */
  111. extern const stream_template s_DCTD_template;
  112. extern const stream_template s_DCTE_template;
  113.  
  114. /* Define an internal procedure for setting stream defaults. */
  115. /* Clients do not call this. */
  116. void s_DCT_set_defaults(P1(stream_state * st));
  117.  
  118. #endif /* sdct_INCLUDED */
  119.